package _Pan3D.program.shaders
{
	import _Pan3D.program.Shader3D;
	
	public class GroundShader extends Shader3D
	{
		public static var GROUND_SHADER:String = "GROUND_SHADER";
		public function GroundShader()
		{
			vertex = 
				"m44 vt0, va0, vc4 \n" +
				"m44 vt1, vt0, vc0 \n" +
				"m44 v5, va0, vc8 \n" +
				"m44 v7, va0, vc12 \n" +

		
		
				
				"mov op, vt1 \n" +
				"mov v0, va1 \n" + 
				"mov v6, va0 \n" +
				"mov v2, va2";
			
			fragment =
				
				
				
				"tex ft0, v0, fs1 <2d,clamp,repeat>\n"+ //将本身的贴图对应上
				
				
				//用跟据太阳镜头算出的点。进行阴影贴图对应
				"mov ft5,v5\n"+
				"div ft5,ft5,ft5.z \n"+
				"neg ft5.y,ft5.y \n"+
				"add ft4,ft5,fc2.z \n"+
				"tex ft5, ft4, fs2 <2d,2d,2d>\n"+   
				"mul ft0,ft0,ft5\n"+
			
				//加上法线方向运算
				"dp3 ft2.x,fc0,v2\n"+
				"mul ft2.x,ft2.x,fc1.w\n"+
				"mul ft2,ft0,ft2.x\n"+
				/*隐藏法线强度
				"add ft0,ft0,ft2\n"+
				"add ft0,ft0,fc1\n"+
				*/
				
				//用跟据太阳镜头算出的点。进行阴影贴图对应
				"mov ft5,v7\n"+
				"div ft5,ft5,ft5.z \n"+
				"neg ft5.y,ft5.y \n"+
				"add ft4,ft5,fc2.z \n"+
				"tex ft5, ft4, fs0 <2d,2d,2d>\n"+  
				//"mov ft5.w,fc2.z \n"+
				
				"sub ft6.w,fc2.w,ft5.w\n"+
				"mul ft0.xyz,ft0.xyz,ft6.w\n"+
				"mul ft5.xyz,ft5.xyz,ft5.w\n"+
				"add ft0.xyz,ft0.xyz,ft5.xyz\n"+
				//"mov ft0.a,fc2.w\n"+
				//"mov ft0.r,fc3.r\n"+
				
			
	        
				
				"mov oc, ft0"
		}
	}
}